<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('疫情防控人员管理添加页面（委外）')" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <!-- 引入 Bootstrap -->
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <style>
        .container {
            padding-right: 0px;
            padding-left: 0px;
        }
    </style>
</head>
<body class="white-bg" style="font-size: 16px">
<!--<h4 style="text-align: center; background-color: #0C72D1;color: white; padding:10px;"><span th:text="${deptName}"></span></span></h4>-->
<input id="curDeptId" type="hidden" th:value="${deptId}"></input>
<div class="container" id="permDiv" style="display: block;margin: 10px 5px 5px 5px;">
    <div class="form-group">
        <h3 style="font-size: 16px"><label class="col-sm-12"><i class="text-danger">*</i> 部门：</label></h3>
        <div class="col-sm-12">
            <input type="text" class="form-control" name="userName" th:value="${deptName}" required="required" disabled="disabled">
        </div>
    </div>
    <div class="form-group">
        <h3 style="font-size: 16px"><label class="col-sm-12"><i class="text-danger">*</i> 姓名：</label></h3>
        <div class="col-sm-12">
            <input type="text" placeholder="请输入员工姓名" class="form-control" name="userName" id="userName" required="required">
        </div>
    </div>
    <div class="form-group">
        <h3 style="font-size: 16px"><label class="col-sm-12"><i class="text-danger">*</i> 手机号：</label></h3>
        <div class="col-sm-12">
            <input type="number" placeholder="请输入员工手机号" class="form-control" name="phonenumber" id="phonenumber" required="required">
        </div>
    </div>
    <div style="text-align: center; margin: 10px;" id="addUserBtn">
        <button style="width: 100%;font-size: 16px" type="button" class="btn btn-primary" onclick="submitAddExUser()">添加</button>
    </div>
</div>
<!-- jQuery (Bootstrap 的 JavaScript 插件需要引入 jQuery) -->
<script src="https://code.jquery.com/jquery.js"></script>
<!-- 包括所有已编译的插件 -->
<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var prefix = ctx + "wxcp/epidemic/collect";
    function submitAddExUser() {
        var curDeptId = $('#curDeptId').val();
        //手机号正则
        var phoneReg = /^[1][2,3,4,5,6,7,8,9][0-9]{9}$/;
        var userName = $("#userName").val();
        var phonenumber = $("#phonenumber").val();
        if (userName == undefined || userName == null || userName == '' || userName.length == 0) {
            $.modal.alertWarning("请输入员工姓名");
            return;
        }
        if (phonenumber == undefined || phonenumber == null || phonenumber == '' || phonenumber.length == 0 || !phoneReg.test(phonenumber)) {
            $.modal.alertWarning("请输入员工手机号");
            return;
        }
        $.modal.confirm("确定添加当前成员到该部门下吗？", function() {
            $.post(prefix+"/user/addUserEx",{deptId: curDeptId, userName:userName, phonenumber: phonenumber },function(result){
                if (result.code == web_status.SUCCESS) {
                    window.location.href = prefix + "/userManage";
                }else if (result.code == web_status.WARNING) {
                    $.modal.alertWarning(result.msg)
                }
            });
        });
    }
</script>
</body>
</html>
